<template>
  <div>
    <div id="joinTop">
      <div id="joinTopL" class="joinTop">我加入的</div>
      <div id="joinTopR" class="joinTop" @click.stop="toAllCircle">全部圈子
        <van-icon style="top: 1px" name="arrow"/>
      </div>
    </div>
    <div class="joinMain">
      <ul class="warp">
        <li class="joinItem">
          <div class="joinItemMain"
               @click.stop="$router.push('/index/explore/allcircle')"
               style="display: flex;justify-content: center;align-items: center;border:1px dashed #000;"
           >
            <div style="font-size: x-large;">
              <van-icon name="plus"/>
              <div style="font-size: 13px;color: #494949;">发现更多</div>
            </div>
          </div>
        </li>
        <li class="joinItem" v-for="(item,index) in circle" @click="$router.push('/index/explore/circledetailed?id='+item.id)">
          <div class="joinItemMain">
            <div id="circleImg">
              <img :src="item.head" alt="">
            </div>
            <div id="circleName">
              {{item.circleName}}
            </div>
          </div>
        </li>
      </ul>
    </div>
    <div id="joinDetail">
      <talk-card
          v-for="(item,index) in activities"
          :name="item.user.userName"
          :avatar="item.user.userHead"
          :time-ago="item.updateTime"
          :num="item.loveNumber"
          :text="item.content"
          :id="item.id"
          :activity-name="item.activityName"
          :picture="item.picture"
          :like="item.love"
      ></talk-card>
      <div style="height: 44px"></div>
    </div>
  </div>
</template>

<script>
import talkCard from '@/components/TalkCard/index';

export default {
  name: "ECircle",
  data() {
    return {
      circle: [],
      activities: []
    }
  },
  components: {
    talkCard
  },
  created() {
    this.request();
  },
  methods: {
    getAllCircles() {
      return axios.get('/circle/getFollowCircle', {
        params: {
          curPage: 1,
          pageSize: 10
        },
        headers: {isShowFullLoading: 'F'}
      })
    },
    getAllActivities() {
      return axios.get('/activity/getByFollowCircle', {
        params: {pageSize: 20},
        headers: {isShowFullLoading: 'F'}
      })
    },
    request() {
      return axios.all([this.getAllCircles(), this.getAllActivities()])
          .then(axios.spread((circles, activities) => {
            this.circle = [];
            this.circle.push(...circles.result.result);
            this.activities = [];
            this.activities.push(...activities.result.result);
            // console.log(typeof activities.result.result[0].love);
            //数据整理
            this.activities = this.activities.map((item) => {
              item.updateTime = _g.timeAgo(item.updateTime);
              item.picture = [];
              if (item.picture1) {
                item.picture.push(item.picture1);
              }
              if (item.picture2) {
                item.picture.push(item.picture2);
              }
              if (item.picture3) {
                item.picture.push(item.picture3);
              }
              return item;
            })
          }));
    },
    toAllCircle() {
      console.log(12);
      this.$router.push('/index/explore/allcircle')
    }
  }
}
</script>

<style scoped>
#joinDetail {
  margin-top: 8px;
  /*margin-bottom: 44px;*/
}

.joinTop {
  font-size: 13px;
  color: #494949;
  display: inline-block;
  margin-top: 10px;
}

#joinTopR {
  float: right;
  margin-right: 2px;
}

#joinTopL {
  margin-left: 5px;
}

.joinMain {
  margin-top: 3px;
  width: 100%;
  max-width: 750px;
  min-width: 320px;
}

.joinItemMain {
  border-radius: 12%;
  height: 100px;
  width: 80px;
  position: relative;
}

.warp {
  white-space: nowrap;
  overflow-x: auto;
  list-style: none;
  padding-left: 0;
}

.joinItem {
  display: inline-block;
  width: 80px;
  height: 102px;
  margin-right: 15px;
  background: #ffffff;
  text-align: center;
  position: relative;
  border-radius: 12%;
  vertical-align: top;
}

#circleImg > img {
  height: 100px;
  width: 80px;
  border-radius: 12%;
}

#circleName {
  position: absolute;
  left: 10px;
  bottom: 0;
  color: white;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  width: 70px;
}

.joinItem:last-child {
  margin-right: 0;
}

.joinItem:first-child {
  margin-left: 10px;
}

.warp::-webkit-scrollbar {
  width: 0 !important
}

.warp {
  -ms-overflow-style: none;
}

.wrap {
  overflow: -moz-scrollbars-none;
}
</style>
